<?php

/**
 * This is the model class for table "zy_activity_classify".
 *
 * The followings are the available columns in table 'zy_activity_classify':
 * @property integer $activity_classify_id
 * @property string $classify_name
 * @property integer $is_delete
 * @property string $crate_time
 * @property string $crate_user
 * @property string $update_time
 * @property string $update_user
 */
class ActivityClassify extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return ActivityClassify the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'zy_activity_classify';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('is_delete,user_id', 'numerical','integerOnly'=>true),
			array('classify_name', 'length', 'max'=>300),
			array('crate_user, update_user', 'length', 'max'=>50),
			array('crate_time, update_time', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('activity_classify_id, classify_name,user_id, is_delete, crate_time, crate_user, update_time, update_user', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'activity_classify_id' => Yii::t('base','Activity Classify Id'),
			'classify_name' => Yii::t('base','Classify Name'),
			'user_id' => 'user_id',
			'is_delete' => 'Is Delete',
			'crate_time' => 'Crate Time',
			'crate_user' => 'Crate User',
			'update_time' => 'Update Time',
			'update_user' => 'Update User',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('activity_classify_id',$this->activity_classify_id);
		$criteria->compare('classify_name',$this->classify_name,true);
		$criteria->compare('user_id',yii::app()->user->id);
		$criteria->compare('is_delete',0);
		$criteria->compare('crate_time',$this->crate_time,true);
		$criteria->compare('crate_user',$this->crate_user,true);
		$criteria->compare('update_time',$this->update_time,true);
		$criteria->compare('update_user',$this->update_user,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
	
	function getClassifyName($name){
		if($name != ''){
			if($name == '全奖'){
				return Yii::t('base','The full prize');
			}else{
				return Yii::t('base','Lucky draw');
			}
		}
	}
	
	
	
	
}